#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 2e5 + 5;
int a[maxn], n;
int DFS(int t[], int temp){
    // cout << temp << ' ' << n << endl;
    if(temp == n){
        int ans = 0;
        for(int i = 1;i <= n;i ++){
            // cout << t[i] << ' ';
            for(int j = i - 1;j >= 1;j --){
                if(t[i] == t[j]){
                    if(a[i] == a[j])ans += a[i];
                    break;
                }
            }
        }
        // if(ans == 4)cout << "here!!";
        // cout << endl;
        return ans;
    }
    t[temp + 1] = 1;
    int suml = DFS(t, temp + 1);
    t[temp + 1] = 0;
    int sumr = DFS(t, temp + 1);
    return max(suml, sumr);
}
signed main(){
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    cin.tie(0);cout.tie(0);
    int T;cin >> T;
    while(T --){
        cin >> n;
        for(int i = 1;i <= n;i ++) cin >> a[i];
        int t[maxn];
        cout << DFS(t, 0) << endl;
    }
}